package com.nbsystem.service.impl;

import com.nbsystem.dao.ElcNoticeDao;
import com.nbsystem.entity.ElcComment;
import com.nbsystem.dao.ElcCommentDao;
import com.nbsystem.entity.ElcNotice;
import com.nbsystem.service.ElcCommentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (ElcComment)表服务实现类
 *
 * @author makejava
 * @since 2021-06-01 15:04:19
 */
@Service("elcCommentService")
public class ElcCommentServiceImpl implements ElcCommentService {
    @Resource
    private ElcCommentDao elcCommentDao;

    private ElcNoticeDao elcNoticeDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public ElcComment queryById(Integer id) {
        return this.elcCommentDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<ElcComment> queryAllByLimit(int offset, int limit) {
        return this.elcCommentDao.queryAllByLimit(offset, limit);
    }

    @Override
    public List<ElcComment> queryAll(ElcComment elcComment) {
        return this.elcCommentDao.queryAll(elcComment);
    }



//    @Override
//    public List<ElcNotice> queryAll(ElcNotice elcNotice) {
//        return this.elcNoticeDao.queryAll(elcNotice);
//    }

    /**
     * 新增数据
     *
     * @param elcComment 实例对象
     * @return 实例对象
     */
    @Override
    public ElcComment insert(ElcComment elcComment) {
        this.elcCommentDao.insert(elcComment);
        return elcComment;
    }

    /**
     * 修改数据
     *
     * @param elcComment 实例对象
     * @return 实例对象
     */
    @Override
    public ElcComment update(ElcComment elcComment) {
        this.elcCommentDao.update(elcComment);
        return this.queryById(elcComment.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.elcCommentDao.deleteById(id) > 0;
    }

    @Override
    public boolean deleteByIds(Integer[] ids) {

        for (Integer id:ids){
            this.deleteById(id);
        }
        return false;
    }
}
